package com.ggh.service.impl;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ggh.dao.AirlinesMapper;
import com.ggh.entity.Airlines;
import com.ggh.service.AirlinesService;
import com.ggh.vo.Body;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author ： jsq
 * @date ：2019/10/13 22:24
 * @description : 客服
 * @path : com.ggh.service.impl.RoomRecordServiceImpl
 * @modifiedBy ：
 */
@Service
public class AirlinesServiceImpl extends ServiceImpl<AirlinesMapper, Airlines> implements AirlinesService {
    /**
    * @description :添加客服
    * @return: boolean
    * @date : 2019/10/14 15:15
    * @author : jj
    * @throws
    */
    @Override
    @Transactional(rollbackFor = Exception.class)
    public Body add(Airlines airlines){
        int insert = baseMapper.insert(airlines);
        return Body.newInstance();
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public Body delete(Airlines airlines) {
        int delete = baseMapper.delete(new QueryWrapper<Airlines>().eq("name", airlines.getName()).eq("phone", airlines.getPhone()));
        if (delete > 0) {
            return Body.newInstance();
        } else {
            return Body.newInstance(500, "删除失败");
        }
    }
}
